<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Asort extends Controller {

    public function before() {
        parent::before();

        if (!Cookie::get('admin', null) || !$this->request->is_ajax()) die('Access denied');
    }

    public function action_set() {
        try {
            ORM::factory($this->request->param('model'), $this->request->param('id'))
                //->where('id', '=', $this->request->param('id'))
                ->set('sort', $this->request->post('value'))
                ->save();
            die(json_encode(array('status' => 'ok')));
        } catch (Exception $e) {
            die(json_encode(array('status' => 'error', 'data' => $e)));
        }
    }

}